import Vue from 'vue'
import Router from 'vue-router'
import login from '@/components/login'
import home from '@/components/home'
import demo from '@/components/demo'
//文章管理
import articalList from '@/components/artical/articalList'
import signList from '@/components/artical/signList'
import commentList from '@/components/artical/commentList'
//用户管理
import userList from '@/components/user/userList'
//广告管理
import adList from '@/components/advert/adList'
//问答管理
import answerList from '@/components/answer/answerList'


Vue.use(Router)
//避免到当前位置的冗余导航（用于处理转路由到自身的报错）
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  routes: [
    {
      path: '/login',
      name: 'login',
      component: login
    },
    {
      path: '/',
      name: 'home',
      component: home
    },
    {
      path: '/demo',
      name: 'demo',
      component: demo
    },
    {
      path: '/artical/articalList',
      name: 'articalList',
      component: articalList
    },
    {
      path: '/artical/signList',
      name: 'signList',
      component: signList
    },
    {
      path: '/artical/commentList',
      name: 'commentList',
      component: commentList
    },
    {
      path: '/user/userList',
      name: 'userList',
      component: userList
    },
    {
      path: '/advert/adList',
      name: 'adList',
      component: adList
    },
    {
      path: '/answer/answerList',
      name: 'answerList',
      component: answerList
    }
  ]
})
